package com.shycloud.mido.member.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shycloud.mido.member.api.entity.OnlineCoursePeriod;
import com.shycloud.mido.member.api.vo.OnlineCoursePeriodVO;
import com.shycloud.mido.organ.api.dto.OrganizationDTO;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author Xiaoxing Yu
 * @date 2020/10/16
 **/
public interface OnlineCoursePeriodMapper extends BaseMapper<OnlineCoursePeriod> {

	Boolean updateMostRecentEndTimeByDate(@Param(value = "endTime") LocalDateTime endTime,
										  @Param(value = "courseDate") String courseDate,
										  @Param(value = "courseId") Long courseId);

	Boolean updateMostRecentEndTimeByDateAndUsers(@Param(value = "endTime") LocalDateTime endTime,
										  @Param(value = "courseDate") String courseDate,
										  @Param(value = "studentId") String studentId,
										  @Param(value = "teacherId") String teacherId);

	Boolean updateMostRecentEndTimeByDateNoNullCheck(@Param(value = "endTime") LocalDateTime endTime,
										  			 @Param(value = "courseDate") String courseDate,
													 @Param(value = "courseId") Long courseId);

	Boolean deleteMostRecentRecord(@Param(value = "courseDate") String courseDate,
													 @Param(value = "courseId") Long courseId);

	Boolean deleteMostRecentRecordByUsers(@Param(value = "courseDate") String courseDate,
								   @Param(value = "studentId") String studentId,
								   @Param(value = "teacherId") String teacherId);

	List<OnlineCoursePeriodVO> selectPeriodByDateStr(@Param(value = "dateStr") String dateStr,
													 @Param(value = "studentId") String studentId,
													 @Param(value = "teacherId") String teacherId);

	IPage<OnlineCoursePeriodVO> pageAllPeriodByTimeDesc(IPage<OnlineCoursePeriodVO> page,
														@Param(value = "studentId") String studentId,
														@Param(value = "teacherId") String teacherId);

	List<OnlineCoursePeriodVO> selectUnfinishedPeriodListToday(@Param(value = "todayStr") String todayStr);

}
